module.exports = function($scope, $state, $stateParams, $modalInstance,$resource,$modal,toaster, id, item){
   $scope.info = {
      'id' :id,
      'city_first_opinion' : ''
    }
    // 查询所有评定员
    // 随机抽出一个评定员
    $resource('/api/as/goc/sincerityAlevelApplyAd/findEvaluatePeopleList', {}, {}).
    save({},function(res) {
        if (res.errcode !== 0) {
            toaster.error({title:"",body:res.errmsg});
            return;
        }
        console.log('所有评定员');
        console.log(res);
        $scope.peopleArr = res.data;
    })
    $scope.ok = function (ss){
      console.log($scope.info);
        $resource('/api/as/goc/sincerityAlevelApplyAd/updateAlevelApplyCityOn', {}, {})
        .save($scope.info, function (res) {
            if (res.errcode !== 0) {
                toaster.error({ title: "提示", body: res.errmsg });
                return;
            }
            var value = $scope.peopleArr[Math.round(Math.random()*($scope.peopleArr.length-1))];  //随机抽取一个值
            console.log(value);
            $resource('/api/ac/goc/sincerityAlevelApplyService/createViewAlevelApplyCategory', {}, {}).
            save({'apply_type' : item.apply_type, 'apply_id' : item.id, 'people_login' : value.people_login, 'people_id' : value.people_id},function(res) {
                if (res.errcode !== 0) {
                    toaster.error({title:"",body:res.errmsg});
                    return;
                }
                toaster.success({title:"",body:'操作成功'});
                $modalInstance.close();
            })
        });
    }
        $scope.cancel = function () {
         $modalInstance.close();
       }
}
  